/*
 */

package labeledbox;

import java.awt.Color;
import java.awt.Rectangle;

/**
 */
public class AbstractShape {

  // Class Vars
  private int left, top;      // upper and left corner of the shape
  private int width, height;  // The size of the shape
  private Color fillColor;    // The fill color of the shape
  private Color lineColor;    // The boundary color of the shape
  private boolean filled = true;     // True if the shape should be filled and false otherwise
  private boolean border = true;     // True if the shape should have a border and false otherwise
  private Rectangle bbox;

  final static int DEFAULT_LEFT = 0;
  final static int DEFAULT_TOP  = 0;
  final static int DEFAULT_WIDTH   = 40;
  final static int DEFAULT_HEIGHT  = 40;

  // Constructor
  public AbstractShape() {

    left = DEFAULT_LEFT;
    top  = DEFAULT_TOP;
    width  = DEFAULT_WIDTH;
    height = DEFAULT_HEIGHT;

    bbox = new Rectangle(left, top, width, height);
  }

  //  Returns TRUE if the shape contains the point and FALSE otherwise.
  //  The shape's BOUNDING BOX determines whether or not the shape contains the point.
  boolean contains(int x, int y) {

    if(bbox.contains(x, y)) return true;
    else                    return false;
  }


  /////////////////////////////
  //// GETTERS & SETTERS //////

  public boolean getBorder() {
    return border;
  }

  public void setBorder(boolean border) {
    this.border = border;
  }

  public Color getFillColor() {
    return fillColor;
  }

  public void setFillColor(Color fillColor) {
    this.fillColor = fillColor;
  }

  // returns the whether or not the shape's filled property is true
  public boolean getFilled() {
    return filled;
  }

  public void setFilled(boolean filled) {
    this.filled = filled;
  }

  public int getHeight() {
    return height;
  }

  public void setHeight(int height) {
    this.height = height;
    this.bbox.setSize(this.getWidth(), height);
  }

  public int getLeft() {
    return left;
  }

  public void setLeft(int left) {
    this.left = left;
    this.bbox.setLocation(this.left, this.top);
  }
  // returns the boundary color of the shape
  public Color getLineColor() {
    return lineColor;
  }

  public void setLineColor(Color lineColor) {
    this.lineColor = lineColor;
  }

  public int getTop() {
    return top;
  }

  public void setTop(int top) {
    this.top = top;
    this.bbox.setLocation(this.left, this.top);
  }

  public int getWidth() {
    return width;
  }

  public void setWidth(int width) {
    this.width = width;
    this.bbox.setSize(width, this.getHeight());
  }

  //// end Getters & Setters ////
  ///////////////////////////////

} //////////////////// end class AbstractShape /////////////////////////////
